package tw.com.hitevision.whiteboard.android.display;

import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class DisplayControlNewlineChina {
    /**
     * 1. 批註啟動
     *   action = "com.hht.action.USBTOUCH.DISABLE"
     * 2. 批註關閉
     *   action = "com.hht.action.USBTOUCH.ENABLE"
     * 3. 按下穿透按鈕啟動穿透
     *   action = "com.hht.action.USBTOUCH.ENABLE" , key ="is_set_on_button" contnt = true
     * 4. 關閉穿透
     *   action = "com.hht.action.USBTOUCH.ENABLE" , key ="is_set_on_button" contnt = false
     * 5. 啟動穿透離開批註
     *   action = "com.hht.action.USBTOUCH.ENABLE"
     * 6. 關閉穿透離開批註
     *   action = "com.hht.action.USBTOUCH.ENABLE"
     *
     * By emo, rules from Wechat
     */

    /***
     * A : 當直接啟動批註時，區域觸碰預設應該是關閉的狀態，發DISABLE，不需判斷，直接關閉區域觸碰
     *
     * B : 當我按下白板區域觸碰按鈕，啟動區域觸碰時，發ENABLE，並且is_set_on_button 為 true，開啟區域觸碰，並讓系統判斷
     *
     * C : 當我按下白板區域觸碰按鈕，關閉區域觸碰時，發ENABLE，並且is_set_on_button 為 false，關閉區域觸碰，並讓系統判斷
     *
     * D : 當我在區域觸碰已經啟動的狀態，直接從批註切回白板時，發DISABLE，關閉區域觸碰
     *
     * E : 白板退出，發ENABLE，開啟區域觸碰
     *
     * By Yuda
     */

    private static final String TAG = DisplayControlNewlineChina.class.getSimpleName();
    private static final String USBTOUCH_DISABLE = "com.hht.action.USBTOUCH.DISABLE";
    private static final String USBTOUCH_ENABLE = "com.hht.action.USBTOUCH.ENABLE";
    private static final String IS_SET_ON_BUTTON = "is_set_on_button";

    public void enableUsbTouch(Context context) {
        Log.d(TAG, "Send broadcast : " + USBTOUCH_ENABLE);
        Intent intent = new Intent(USBTOUCH_ENABLE);
        context.sendBroadcast(intent);
    }

    public void disableUsbTouch(Context context) {
        Log.d(TAG, "Send broadcast : " + USBTOUCH_DISABLE);
        Intent intent = new Intent(USBTOUCH_DISABLE);
        context.sendBroadcast(intent);
    }

    public void toggleDisplayControl(Context context, boolean isSetOnButton) {
        Log.d(TAG, "Send broadcast : " + USBTOUCH_ENABLE + ", " + IS_SET_ON_BUTTON + " : " + isSetOnButton);
        Intent intent = new Intent(USBTOUCH_ENABLE);
        intent.putExtra(IS_SET_ON_BUTTON, isSetOnButton);
        context.sendBroadcast(intent);
    }
}

